
 

function initSuggest(){
$('#searchproductkeyword').autocomplete('/bsierp_cn/user/buyer/autocomplete.jsp',{});
}








//////////////////////////////////////////////////////////////


function searchproductCallback(page_id, jq){
	$('#Searchresult_searchproduct').text("当前查询结果： "+((page_id*10)+1)+"-"+((page_id*10)+10));
	searchProduct((page_id*10),'10','div_searchproduct_rusultcontianer');
}


	function searchProductPage(){
		var searchproductkeyword= dwr.util.getValue("searchproductkeyword") ;
		var searchproductcontactperson= dwr.util.getValue("searchproductcontactperson");
		UserAction.searchProductTotalRecord(searchproductkeyword,searchproductcontactperson,function(data){
		 
		$("#Pagination_searchproduct").pagination(data, {
			num_edge_entries: 2,
			num_display_entries: 8,
			prev_text:"上一页",
			next_text:"下一页",
			callback: searchproductCallback
			} );
		});
		searchProduct('0','10','div_searchproduct_rusultcontianer');
		}


	function searchProduct(firstResult,maxResults,idtoshow){
		var searchproductkeyword= dwr.util.getValue("searchproductkeyword") ;
		var searchproductcontactperson= dwr.util.getValue("searchproductcontactperson");
		UserAction.searchProduct(firstResult,maxResults,searchproductkeyword,searchproductcontactperson,function(data){
			 dwr.util.setValue(idtoshow, data, { escapeHtml:false });
			 initHighslide();
			});
		}
	

/////////////////////////////////////////////////////////////////////////	


	function showImportProductOfSellerBatchBox(form){
		hiBox('#div_message_box', '请选择产品组','300','100','','.a_close');
		var content='<input type="button" value="导入" onClick="importProductOfSellerBatch(\''+form+'\') ">';
		includePageA(gpga,'popup_message',content);
		
	}

	function importProductOfSellerBatch(form){
	var productgroupId= dwr.util.getValue("productgroupforimportproduct");
	var cp=getAllSelectedCheckBoxValues(form);
	if(cp.length>0&&productgroupId!=0){
	UserAction.importProductOfSellerBatch(cp,productgroupId,function(data){
		hiAlert(data, '注意');
	});
	}else{
		hiAlert('请至少选择一个需要导入的产品 ！', '注意');
	}
}
/////////////////////////////////////////////////////////////////////////
	
	
	function showAddOrderBox(productId,productName,productModel,productprice){
		hiBox('#div_message_box', '请填写订单参数','600','450','','.a_close');
		var startContent="<input id=orderproductid  type=hidden value="+productId+">"+"产品名称："+productName+"<br/><br/>产品型号："+productModel+"<br/>我的价格:"+productprice;
		startContent=startContent+"<br/>购买数量<input id=orderproductamount type=text value=1 size=20>总额<input type=text disabled=true value="+productprice+">";
		
		var endContent='<input type="button" value="确定" onClick="preAddOrder()">';
		includePageB(addorder,'popup_message',startContent,endContent);
		
	}

	
	
	function getColorStr(showboxid,colorchartselect){
		var chartid=dwr.util.getValue(colorchartselect);
		UserAction.getColorStr(chartid,
		function(data){
			 dwr.util.setValue(showboxid, data, { escapeHtml:false });
		}
		);
	}
	
	
	
	function getProductParameter(selectId,showBox,productId){
		var selectValue=dwr.util.getValue(selectId);
		var productId=dwr.util.getValue(productId);
		if(selectValue=="CustomMade"){
			getProductParameterStr(showBox,productId,'buyer');	//buyer是给JAVA方法传递的一个识别参数
		}else{
			dwr.util.setValue(showBox,'');
		}
		
	}
	
	function getInputBoxsValue(formid){ //返回文本框的值
		var tform=document.forms[formid]; 
		var t=0;
		var b=new Array();
		for(var i=0;i<tform.length;i++){ 
		var e=tform.elements[i]; 
		if(e.type=="text"){
		b[t]=e.value;
		t++;
		 }
		} 
		return b;
		}
	
	
	function getProudctParameterAndValuesStr(formid){ //返回文本框value属性值与alt属性值的累加
		var tform=document.forms[formid]; 
		var s="";//
		var retVal="";
		for(var i=0;i<tform.length;i++){ 
		var e=tform.elements[i]; 
		if(e.type=="text"){
			retVal=retVal+e.alt+":"+e.value+s;
				 }
		} 
		return retVal;
		}
	
	
	
	
	function checkAllParameterNotNull(formid){
		var inputBoxValues=getInputBoxsValue(formid);
		var isok=true;
		for(var i=0;i<inputBoxValues.length;i++){
			if(inputBoxValues[i]==""){
				isok=false;
			}
			}
		if(inputBoxValues.length==0){
			isok=false;
		}
		return isok;
	}
	
	function setProductColor(showBox,colorChartName,colorId){
		var color=colorChartName+document.getElementById(colorId).innerHTML;
	    dwr.util.setValue(showBox,color, { escapeHtml:false });
		
	}
	
	function preAddOrder(){
		var productId=dwr.util.getValue('orderproductid');
		var productAmount=dwr.util.getValue('orderproductamount');
		var productColor=dwr.util.getValue('productcolor');
		var productSize=dwr.util.getValue('sizeselect');
		var orderDeadline=dwr.util.getValue('orderdeadline');
		var orderRemarks=dwr.util.getValue('orderremarks');
		if(productSize=="CustomMade"){//如果是自定义尺寸模式 
			if(checkAllParameterNotNull('productparameterform')==true){//并且所有的尺码表单都不为空
				productSize=getProudctParameterAndValuesStr('productparameterform');//此时productSize值就为客户填写的表单的值
			}
		}
	 if(productSize=="CustomMade"&&checkAllParameterNotNull('productparameterform')==true){//当尺码为客户自定义时并且每个尺码值不为空

			addOrder(productId,productAmount,productColor,productSize,orderDeadline,orderRemarks,'1');
			
	    }else if(productSize!="CustomMade"){//当尺码为标准码号时

			addOrder(productId,productAmount,productColor,productSize,orderDeadline,orderRemarks,'0');
		
	    }
	
	}
	
	
	function addOrder(productId,productAmount,productColor,productSize,orderDeadline,orderRemarks,orderCustommade){
		if(productId!=""&&productAmount!=""&&productColor!=""&&productSize!=""&&orderDeadline!=""&&orderCustommade!=""){
			UserAction.addOrder(productId,productAmount,productColor,productSize,orderDeadline,orderRemarks,orderCustommade,function(data){hiAlert(data, '注意');});
		}else{
			hiAlert('除备注外所有可填写的表单都是必须填写的，请填写完整！', '注意')
		}
	}
	
	
////////////////////////////////////////////////////////////////////////
	function queryOrderForBuyerCallback(page_id, jq){
		$('#Searchresult_queryorderforbuyer').text("当前查询结果： "+((page_id*10)+1)+"-"+((page_id*10)+10));
		queryOrderForBuyer((page_id*10),'10','div_queryorderforbuyer_rusultcontianer');
	}


		function queryOrderForBuyerPage(){
			var orderid= dwr.util.getValue("buyerordermanage_orderid") ;
			var modelorname= dwr.util.getValue("buyerordermanage_productmodelorname");
			var orderstartdate= dwr.util.getValue("buyerordermanage_orderstartdate");
			var orderenddate= dwr.util.getValue("buyerordermanage_orderenddate");
			var seller= dwr.util.getValue("buyerordermanage_seller");
			var orderstate= dwr.util.getValue("buyerordermanage_orderstate");
			if(orderid==""){
				orderid="0";
			}
			if(orderstate==""){
				orderstate="0";
			}
			if(seller==""){
				seller="0";
			}
			
			UserAction.queryOrderForBuyerTotalRecord(orderid,modelorname,orderstartdate, orderenddate,seller,orderstate,function(data){
			 
			$("#Pagination_queryorderforbuyer").pagination(data, {
				num_edge_entries: 2,
				num_display_entries: 8,
				prev_text:"上一页",
				next_text:"下一页",
				callback: queryOrderForBuyerCallback
				} );
			});
			queryOrderForBuyer('0','10','div_queryorderforbuyer_rusultcontianer');
			}


		function queryOrderForBuyer(firstResult,maxResults,idtoshow){
			var orderid= dwr.util.getValue("buyerordermanage_orderid") ;
			var modelorname= dwr.util.getValue("buyerordermanage_productmodelorname");
			var orderstartdate= dwr.util.getValue("buyerordermanage_orderstartdate");
			var orderenddate= dwr.util.getValue("buyerordermanage_orderenddate");
			var seller= dwr.util.getValue("buyerordermanage_seller");
			var orderstate= dwr.util.getValue("buyerordermanage_orderstate");
			if(orderid==""){
				orderid="0";
			}
			if(orderstate==""){
				orderstate="0";
			}
			if(seller==""){
				seller="0";
			}
	   			UserAction.queryOrderForBuyer(firstResult,maxResults,orderid,modelorname,orderstartdate, orderenddate,seller,orderstate,function(data){
				 dwr.util.setValue(idtoshow, data, { escapeHtml:false });
				 initHighslide();
				});
			}
		






//////////////////////////////////////////////////////////////////////////
				function summaryOrderForBuyer(idtoshow){
				var modelorname= dwr.util.getValue("buyerordersummary_productmodelorname");
				var orderstartdate= dwr.util.getValue("buyerordersummary_orderstartdate");
				var orderenddate= dwr.util.getValue("buyerordersummary_orderenddate");
				var seller= dwr.util.getValue("buyerordersummary_seller");
				var orderstate= dwr.util.getValue("buyerordersummary_orderstate");
			
				if(orderstate==""){
					orderstate="0";
				}
				if(seller==""){
					seller="0";
				}
		   			UserAction.summaryOrderForBuyer(modelorname,orderstartdate, orderenddate,seller,orderstate,function(data){
					 dwr.util.setValue(idtoshow, data, { escapeHtml:false });
					
					});
				}
			


	
		
/////////////////////////////////////////////////////////////////////////
				
				function queryNewArrivalProductCallback(page_id, jq){
					$('#Searchresult_querynewarrival').text("当前查询结果： "+((page_id*10)+1)+"-"+((page_id*10)+10));
					queryNewArrivalProduct((page_id*10),'10','div_querynewarrival_rusultcontianer');
				}


					function queryNewArrivalProductPage(){
						  
						    
							UserAction.queryNewArrivalProductTotalRecord(function(data){
							$("#Pagination_querynewarrival").pagination(data, {
							num_edge_entries: 2,
							num_display_entries: 8,
							prev_text:"上一页",
							next_text:"下一页",
							callback: queryNewArrivalProductCallback
							} );
						});
						queryNewArrivalProduct('0','10','div_querynewarrival_rusultcontianer');
						}


					function queryNewArrivalProduct(firstResult,maxResults,idtoshow){
						   	UserAction.queryNewArrivalProduct(firstResult,maxResults,function(data){
							 dwr.util.setValue(idtoshow, data, { escapeHtml:false });
							 initHighslide();
							});
						}
					
					function getQueryNewArrivalProductPage(){
						
						DynamicInclude.getInclude(qnap,function(data) {
							   dwr.util.setValue('buyer_display', data, { escapeHtml:false });
							   queryNewArrivalProductPage();
							   });
						
					}
					
/////////////////////////////////////////////////////////////////////////
					
					
					function queryOffenBuyProductCallback(page_id, jq){
						$('#Searchresult_queryoffenbuy').text("当前查询结果： "+((page_id*10)+1)+"-"+((page_id*10)+10));
						queryOffenBuyProduct((page_id*10),'10','div_queryoffenbuy_rusultcontianer');
					}


						function queryOffenBuyProductProductPage(){
							  
							    
								UserAction.queryOffenBuyProductTotalRecord(function(data){
								$("#Pagination_queryoffenbuy").pagination(data, {
								num_edge_entries: 2,
								num_display_entries: 8,
								prev_text:"上一页",
								next_text:"下一页",
								callback: queryOffenBuyProductCallback
								} );
							});
								queryOffenBuyProduct('0','10','div_queryoffenbuy_rusultcontianer');
							}


						function queryOffenBuyProduct(firstResult,maxResults,idtoshow){
							   	UserAction.queryOffenBuyProduct(firstResult,maxResults,function(data){
								 dwr.util.setValue(idtoshow, data, { escapeHtml:false });
								 initHighslide();
								});
							}
						
						function getQueryOffenBuyProductPage(){
							
							DynamicInclude.getInclude(obp,function(data) {
								   dwr.util.setValue('buyer_display', data, { escapeHtml:false });
								   queryOffenBuyProductProductPage();
								   });
							
						}
						

					
					